<template>
  <div style="color: #666;font-size: 14px;">
    <div style="padding-bottom: 20px">
      <b>您好！{{ user.nickname }}</b>
    </div>
    <el-card>
      <div style="padding: 10px 0 20px 0;font-size: 32px;font-weight: bold">
        今天是{{date}}
      </div>
      <div style="font-size: 20px;font-weight: 600">
        <div >上午班是：{{getByShiftId(1)}}</div>
        <div>下午班是：{{getByShiftId(2)}}</div>
        <div>夜班班是：{{getByShiftId(3)}}</div>
      </div>
      <el-divider />
      -------------
    </el-card>

  </div>
</template>

<script>
import dayjs from "dayjs";
export default {
  name: "Home",
  data() {
    return {
      user: localStorage.getItem("user") ? JSON.parse(localStorage.getItem("user")) : {},
      date:dayjs().format("YYYY-MM-DD"),
      shift:[]
    }
  },
  created() {
      this.getShift()
  },
  methods:{
    getByShiftId(id){
     return this.shift.find(i => i.shiftId === id)?.person
    },
    getShift(){
      this.request("/schedule/shift/"+this.date).then(res=>{
        this.shift = res.data
      })
    }
  }
}
</script>
